<template>
  <div class="xscj_box">
    <header-comm></header-comm>
    <div class="bcg">
      <!-- <reservepage></reservepage> -->
      <div class="margin_top">
        <div class="top_reserve">
          <div class="tit">销售抽奖</div>
        </div>
        <div class="xscj">
            <div class="search_box">
                <div></div>
                <div class="rig_inp">
                    <a-input placeholder='请输入查询的关键字' v-model="seac_val" @change="search"/>
                </div>
            </div>
          <a-table
            :columns="reservecolumns"
            :pagination="pagination"
            @change="getxscjlist"
            :dataSource="reservedata"
            bordered
          >
        
           
            <template slot="operation" slot-scope="text, record, index">
              <span class="del" @click="deleter(record.key)">删除</span>
            </template>
          </a-table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import headerComm from "../header-comm/header.vue";

import qs from "qs";
const reservecolumns = [
  {
    title: "公司名称",
    dataIndex: "gsmc",
    scopedSlots: { customRender: "gsmc" }
  },
   {
    title: "联系人",
    dataIndex: "lxr",
    scopedSlots: { customRender: "lxr" }
  },
  {
    title: "联系电话",
    dataIndex: "lxdh",
    scopedSlots: { customRender: "lxdh" }
  },
   {
    title: "登录人手机号",
    dataIndex: "phone",
    scopedSlots: { customRender: "phone" }
  },{
    title: "邮箱",
    dataIndex: "email",
    scopedSlots: { customRender: "email" }
  },
  {
    title: "抽奖码",
    dataIndex: "cjm",
    scopedSlots: { customRender: "cjm" }
  }, {
    title: "时间",
    dataIndex: "dateline",
    scopedSlots: { customRender: "dateline" }
  },
  
  {
    title: "操作",
    dataIndex: "operation",
    scopedSlots: { customRender: "operation" }
  }
];
const reservedata = [];
export default {
  data() {
    return {
      reservedata,
      reservecolumns,
      pagination: {
        defaultPageSize: 10,
        showTotal: total => `共 ${total} 条数据`,
        total: 0,
        current:1
      },
      seac_val:''
      
    };
  },

  methods: {
    getxscjlist(pagination) {
        this.pagination.current=pagination.current
      this.axios
        .post(
          "fhl/xscj/xscjList.php",
          qs.stringify({
            page: this.pagination.current,
            pageSize: pagination.defaultPageSize,
            sqdwid: this.$store.state.bbl_sqdwid,
            filed:this.seac_val,
          })
        )
        .then(res => {
          console.log(res);
          if (res.data.code == 303) {
            this.pagination.total = Number(res.data.result.total);
            this.reservedata = res.data.result.data;
            for (var i = 0; i < this.reservedata.length; i++) {
              this.reservedata[i].key = this.reservedata[i].id_num;
            }
          } else {
            this.reservedata = [];
          }
        });
    },
   
  search(){
      this.pagination.current=1
    this.getxscjlist(this.pagination);


  },
    deleter(key) {
      this.axios
        .post(
          "fhl/xscj/xscjDelete.php",
          qs.stringify({
            id_num: key
          })
        )
        .then(res => {
          if (res.data.code == 303) {
            this.getxscjlist(this.pagination);
            this.$notification["success"]({
              message: "成功",
              description: res.data.msg
            });
          } else {
            this.$notification["error"]({
              message: "失败",
              description: res.data.msg
            });
          }
        });
    }
  },
  components: {
    headerComm
  },
  created() {
    this.getxscjlist(this.pagination);
  }
};
</script>

<style lang='less'>
.margin_top {
  width: 98%;
  margin: 67px auto;
  background: #fff;
  padding: 22px;
  .top_reserve {
    text-align: left;
    font-weight: bold;
    font-size: 18px;
    color: #333;
  }
  .top_reserve {
    padding: 10px;
  }
  .xscj_box {
    .down_box {
      .ico {
        font-size: 20px;
        margin-left: 5px;
        vertical-align: middle;
      }
    }
  
  
  }

}
  .xscj{
  .search_box{
        // text-align: right;
        display: flex;
        justify-content: space-between;
        .rig_inp{
            padding: 20px 0;
        }
    }
    }
</style>
